<?php
/**
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file license.txt or that can be found at 
 * http://code.google.com/p/billboardce/wiki/License.
 *
 * @package    Image_Data
 * @category   Model
 * @license    http://code.google.com/p/billboardce/wiki/License New BSD License
 * @version    SVN: $Id: $
 */
class Image_Data extends Ot_Db_Table
{
    /**
     * Name of the table in the database
     *
     * @var string
     */
    protected $_name = 'tbl_plugin_slidetype_image';
  
    /**
     * Primary key of the table
     *
     * @var string
     */
    protected $_primary = 'slideId';

    /**
     * Generates the form for adding and editing a slide's URL
     * 
     * @param array $values The values the form should be populated with
     * @return Zend_Form
     */
    public function form($values = array())
    {
        $form = new Zend_Form();
        $form->setAttrib('class', 'slideTypeForm')
             ->setDecorators(array(
                     'FormElements',
                     array('HtmlTag', array('tag' => 'div', 'class' => 'zend_form')),
                     'Form'
             ));
             
        $url = $form->createElement('text', 'url', array('label' => 'Image Url:'));
        $url->setValue(isset($values['url']) ? $values['url'] : '');
        
        $bgColor = $form->createElement('text', 'bgColor', array('label' => 'Background Color:'));
        $bgColor->setAttrib('size', 6)
                ->setAttrib('maxlength', 6);
        $bgColor->setValue(isset($values['bgColor']) ? $values['bgColor'] : '');        

        $alignmentValues = array(
                                'topLeft'      => 'Top Left',
                                'topCenter'    => 'Top Center',
                                'topRight'     => 'Top Right',
                                'centerLeft'   => 'Center Left',
                                'centerCenter' => 'Center Center',
                                'centerRight'  => 'Center Right',
                                'bottomLeft'   => 'Bottom Left',
                                'bottomCenter' => 'Bottom Center',
                                'bottomRight'  => 'Bottom Right'
                            );
        
        $alignment = $form->createElement('select', 'Alignment', array('label' => 'Alignment:'));
        $alignment->setMultiOptions($alignmentValues)
                  ->setValue(isset($values['alignment']) ? $values['alignment'] : 'centerCenter');
        
        $form->addElements(array($url, $bgColor, $alignment));

        $form->setElementDecorators(array(
                  'ViewHelper',
                  'Errors',
                  array('HtmlTag', array('tag' => 'div', 'class' => 'elm')),
                  array('Label', array('tag' => 'span')),
              ));
        
        return $form;
    }    
}